package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.ActivityUserDao;
import com.x.erp.model.ActivityUser;
import com.x.erp.rpc.ActivityUserRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
@Service(interfaceName = "com.x.erp.rpc.ActivityUserRpcService", timeout = 60000)
public class ActivityUserService extends BaseService implements ActivityUserRpcService {

	@Autowired
	private ActivityUserDao activityUserDao; // 临时活动报名人信息Dao

	/**
	 * 新增活动报名人信息
	 */
	@Override
	public ActivityUser insertActivityUser(ActivityUser activityUser){
		activityUser.setActivityUserSate (0);
		activityUser.setActivityUserCreateTime (new Date ());
		try {
			return this.insert(activityUser);
		} catch (Exception e) {
			throw new BusinessException (ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 删除活动报名人信息
	 */
	@Override
	public int deleteActivityUser(ActivityUser activityUser){
		return this.delete (activityUser);
	}

	/**
	 * 修改活动报名人信息
	 */
	@Override
	public int updateActivityUser(ActivityUser activityUser){
		return this.update (activityUser);
	}

	/**
	 * 查询活动报名人信息
	 */
	@Override
	public ActivityUser selectActivityUser(ActivityUser activityUser){
		try {
			return activityUserDao.selectActivityUser (activityUser);
		} catch (Exception e) {
			throw new BusinessException (ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询所有活动报名人信息
	 */
	@Override
	public List<ActivityUser> selectActivityUserList(ActivityUser activityUser){
		try {
			return activityUserDao.selectActivityUserList (activityUser);
		} catch (Exception e) {
			throw new BusinessException (ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}
}
